{extend name="public/father" /}

{block name='main'}
<div class="layui-tab layui-tab-card">

    <ul class="layui-tab-title">
        <li class="layui-this">
            <a href="{:url('admin/wechat_account/index')}"><i class="layui-icon layui-icon-list"></i> 公众号列表</a>
        </li>
        <li>
            <a href="{:url('admin/wechat_account/create')}"><i class="layui-icon layui-icon-add-1"></i> 添加</a>
        </li>
    </ul>

    <div class="layui-tab-content" style="background: #FFFFFF;">

        <div class="layui-btn-group">
            <form class="layui-form" method="get">
                <button class="layui-btn layui-btn-primary" onclick="javascript:location.reload();"><i class="fa fa-refresh"></i> 刷新当前页面</button>
                <input type="text" name="so" autocomplete="off" value="{:input('param.so')}" placeholder="搜索关键词" class="layui-btn layui-btn-primary">
                <button class="layui-btn layui-btn-primary"><i class="layui-icon layui-icon-search"></i>搜索</button>
                <a class="layui-btn layui-btn-primary" href="{:url()}"><i class="layui-icon layui-icon-ok-circle"></i>显示全部</a>
            </form>
        </div>

        <table id="dataTable"></table>

        <script type="text/html" id="status">
            <input type="checkbox" name="status" lay-skin="switch" lay-text="启用|禁用" data-href="{:url('status')}?t=wechat_accounts&id={{ d.id }}" lay-filter="switchStatus" value="{{ d.status }}" {{ d.status==1 ? 'checked' : '' }}>
        </script>

        <script type="text/html" id="barDemo">
            <div class="layui-btn-group">
                <a class="layui-btn layui-btn-primary layui-btn-xs" href="{:url('edit')}?id={{ d.id }}"><i class="layui-icon layui-icon-edit"></i>改</a>
                <a class="layui-btn layui-btn-primary layui-btn-xs" onclick="del('wechat_accounts', {{ d.id }});"><i class="layui-icon layui-icon-delete"></i>删</a>
            </div>
        </script>
    </div>
</div>
{/block}

{block name="js"}
<script type="text/javascript">
    layui.use(['table', 'layer', 'form'], function() {
        var table = layui.table,
            layer = layui.layer,
            form = layui.form,
            $ = layui.jquery;

        table.render({
            elem: '#dataTable',
            url: "{:url()}?so={:trim(input('param.so'))}",
            title: '数据表',
            limit: 20,
            cols: [
                [
                    {fixed: 'left',		title:'操作',	width:120,	align:'center',	toolbar:'#barDemo'},
                    {field: 'status',	title:'状态',	width:100,	align:'center',	sort:true,	templet:'#status'},
                    {field: 'sort',		title:'排序',	width:90,	align:'center'},
                {field: 'account_name',	title:'公众号名称',	width:150},
                    {field: 'domain',	title:'认证域名', templet: function (d) {
						let domains = d.domain1 ? d.domain1 : '';
							domains += d.domain2 ? '、'+ d.domain2 : '';
							domains += d.domain3 ? '、'+ d.domain3 : '';
							domains += d.domain4 ? '、'+ d.domain4 : '';
							domains += d.domain5 ? '、'+ d.domain5 : '';
		                    return domains;
	                    }},
                    {field: 'app_id',	title:'app_id',	width:150},
                {field: 'app_secret',	title:'app_secret',	width:150},
                {field: 'expire_time',	title:'token到期时间',	width:170,	align:'center'},
                ]
            ],
            page: true
        });
    });
</script>
{/block}
